home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / tlt003.zip / TLT.C < prev    next >
Text File  |  1995-01-03  |  6KB  |  260 lines

  1. /* Text Listy Thing (TLT)
  2.  * By Simon Avery
  3.  * Compiled with PCC and included PCIO and EXEC modules linked in.
  4.  * Version .003  Released 21:44:17  3 January 1995
  5.  * FreeWare - See TLT.DOC for more information
  6.  ***/
  7.  
  8. #include <stdio.h>
  9.  
  10. char *buf1;                     /* Store start-up time in buf1 */
  11.  
  12. void main()
  13. {
  14.         printf("");     /* Ansi code to hide ink */
  15.         times(buf1);            /* Store start-up time in buf1 */
  16.         white();                /* Ansi routine to change to default colours */
  17.         banner3();              /* Show banner3 */
  18.         mainloop();             /* Goto main routine */
  19. }
  20.  
  21. mainloop()
  22. {
  23.         white ();
  24.  
  25.         int wordcount;                  /* Main wedge */
  26.         wordcount = 0;
  27.         FILE *fp1;                      /* Ask for filename */
  28.         char oneword[100],filename[25];
  29.         char *c;
  30.  
  31.         printf("Name of file to view -> ");
  32.         printf(""); /* Ansi code brght yell on blue bgrnd. */
  33.  
  34.         scanf("%s",filename);           /* read the desired filename */
  35.  
  36.         fp1 = fopen(filename,"r");
  37.         if (fp1 == NULL)                /* Check to see if file is there */
  38.         not_there();
  39.  
  40.    else {
  41.         scr_clr();                      /* Found file, print banner 1 and */
  42.         banner1();                      /* show banner1 */
  43.  
  44.    do
  45.  {
  46.       c = fgets(oneword,100,fp1);       /* get one line from the file */
  47.  
  48.          printf("%s",oneword);          /* display it on the monitor  */
  49.          wordcount = wordcount +1;
  50.  
  51.       if (wordcount >= 20)              /* Show 20 lines of text */
  52.  
  53.         {
  54.  
  55.         wordcount=0;
  56.  
  57.         printf("");
  58.         scr_rowcol(23,43);
  59.         printf("File: %s",filename);    /* Print filename at bottom right */
  60.         stopbit ();                     /* Wait for a key... */
  61.         }
  62.  
  63.  } while (c != NULL);                   /* Repeat until end of file */
  64.  
  65. }
  66.    fclose(fp1);
  67.  
  68. white();
  69. banner4();
  70. waitspace();
  71. mainloop();
  72. }
  73.  
  74. void white()
  75. {
  76.         printf("");              /* Ansi code for default DOS colours*/
  77. }
  78.  
  79. quit()
  80. {
  81. white();
  82. exit();
  83. }
  84.  
  85. stopno ()
  86. {
  87.         scr_clr();
  88.         white();
  89.  
  90.         char *buf;                      /* Print time started and time now (ended) */
  91.         times(buf);
  92.         printf("\nTime started: %s.  Time now: %s.\n",buf1,buf);
  93.         printf("Text Listy Thing (TLT V.003) terminated normally. (c) 1995 Simon Avery.  √\n");
  94.         quit();
  95. }
  96.  
  97. stopbit (string)
  98. char *string[];
  99. {
  100.         banner2();
  101.         waitspace();
  102.  
  103.         scr_clr();
  104.         banner1();
  105. }
  106.  
  107. waitspace()
  108. {
  109.                 /* Wait for any key */
  110.  
  111. int c;
  112.       c = getchar("%d",&c);                    /* get a character */
  113.                                                /* and check to see if it's one of the hotkeys */
  114.         if (c == 81)            /* Dec code for 'Q' */
  115.         {stopno();}
  116.         if (c == 113)           /* Dec code for 'q' */
  117.         {stopno();}
  118.         if (c == 27)            /* Dec code for 'esc' */
  119.         {stopno();}
  120.         if (c == 68)            /* D */
  121.         {dirlst();}
  122.         if (c == 100)           /* d */
  123.         {dirlst();}
  124.         if (c == 63)            /* ? */
  125.         {help();}
  126.         if (c == 72)            /* H */
  127.         {help();}
  128.         if (c == 104)           /* h */
  129.         {help();}
  130.  
  131.  
  132.  
  133. }
  134.  
  135. banner1 ()
  136. {
  137.  
  138.                                                 /* Do top banner1 */
  139.  
  140.         time();
  141.  
  142.         printf("");                 /* Ansi code brght yell on blue bgrnd. */
  143.         scr_rowcol(0,14);
  144.         printf(" -= Text Listy Thing (TLT) By Simon Avery =- ");
  145.         printf(""); /* Ansi code black on white bgrnd. */
  146.         scr_rowcol(0,65);
  147.         printf("CyberDwarf!(TM)");
  148.  
  149.         white();
  150.  
  151.         scr_rowcol(2,0);
  152. }
  153.  
  154. banner2()
  155. {
  156.                                         /* Do bottom banner2 */
  157.         scr_rowcol(23,0);
  158.  
  159.         printf(" (Q)uit  (D)ir  (H)elp  Any other key... ");
  160.  
  161.  
  162. /* Now move cursor back to top of screen and start over */
  163.  
  164.         white();
  165.  
  166. }
  167.  
  168. banner4()
  169. {
  170. /* Do bottom banner4 - end of file */
  171.  
  172.         scr_rowcol(23,0);
  173.  
  174.  
  175.         printf(" -= END OF FILE =- (D)ir  (Q)uit  (H)elp    Any other key to cycle.             ");
  176.  
  177. /* Now move cursor back to top of screen and start over */
  178.  
  179.         white();
  180.  
  181. }
  182.  
  183. not_there()
  184. {
  185.         scr_clr();
  186.         scr_rowcol(2,0);
  187.         printf("Sorry, can't find that file.\n\n");
  188.         printf("Press any key to DIR or Q to abort.");
  189.  
  190.         waitspace();
  191.  
  192.         dirlst();
  193.  
  194. }
  195.  
  196. banner3()
  197. {
  198. /* Print Banner1 and move cursor down one line */
  199.         scr_clr();
  200.         banner1();
  201.  
  202.         scr_rowcol(2,1);
  203. }
  204.  
  205. dirlst()
  206. {
  207.         scr_clr();
  208.         banner1();
  209.  
  210.         exec("c:\\dos\\command.com", "/cdir /w");
  211.         mainloop();
  212. }
  213.  
  214. help()
  215. {
  216. /* Really needs a way to save current screen, show help, then swap back in */
  217.  
  218.         scr_clr();
  219.         banner1();
  220.         scr_rowcol(5,15);
  221.       printf("Text Listy Thing needs ANSI.SYS loaded in order to");
  222. scr_rowcol(6,15);
  223.  
  224.       printf("         display the colored headers.             ");
  225. scr_rowcol(8,15);
  226.       printf("This was my first ever 'C' program, written with  ");
  227. scr_rowcol(9,15);
  228.       printf("       PCC and didn't take very long.             ");
  229.  
  230. scr_rowcol(11,15);
  231.       printf("TLT will display any Ansi codes within a document,");
  232. scr_rowcol(12,15);
  233.       printf(" but will get confused about screen lengths with  ");
  234. scr_rowcol(13,15);
  235.       printf("some Ansi picture screens.  Version .003        ");
  236.  
  237. scr_rowcol(15,15);
  238.       printf("D = Stops current file and prompts for a new file.");
  239. scr_rowcol(16,15);
  240.       printf("Q = (or ESC) Halts TLT completely.                ");
  241. scr_rowcol(17,15);
  242.       printf("? = Print this screen.                            ");
  243.  
  244. scr_rowcol(19,15);
  245.       printf("  TLT is Freeware. (C'mon, would *you* buy it?)   ");
  246.  
  247. banner2();
  248. stopbit();
  249. }
  250.  
  251. time()
  252. {
  253.         scr_rowcol(0,0);
  254.         printf(""); /* Ansi code black on white bgrnd. */
  255.  
  256.         char *buf;
  257.         times(buf);
  258.         printf("%s",buf);
  259. }
  260.